<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highscore - The Boost C++ Libraries - Introduction</title>
<link rel="stylesheet" href="css/highscore.css" type="text/css">
<link rev="made" href="mailto:boris@highscore.de">
<link rel="home" href="frontpage.html" title="The Boost C++ Libraries">
<link rel="up" href="frontpage.html" title="The Boost C++ Libraries">
<link rel="prev" href="frontpage.html" title="The Boost C++ Libraries">
<link rel="next" href="smartpointers.html" title="Chapter 2: Smart Pointers">
<link rel="chapter" href="introduction.html" title="Chapter 1: Introduction">
<link rel="chapter" href="smartpointers.html" title="Chapter 2: Smart Pointers">
<link rel="chapter" href="functionobjects.html" title="Chapter 3: Function Objects">
<link rel="chapter" href="eventhandling.html" title="Chapter 4: Event Handling">
<link rel="chapter" href="stringhandling.html" title="Chapter 5: String Handling">
<link rel="chapter" href="multithreading.html" title="Chapter 6: Multithreading">
<link rel="chapter" href="asio.html" title="Chapter 7: Asynchronous Input and Output">
<link rel="chapter" href="interprocesscommunication.html" title="Chapter 8: Interprocess Communication">
<link rel="chapter" href="filesystem.html" title="Chapter 9: Filesystem">
<link rel="chapter" href="datetime.html" title="Chapter 10: Date and Time">
<link rel="chapter" href="serialization.html" title="Chapter 11: Serialization">
<link rel="chapter" href="parser.html" title="Chapter 12: Parser">
<link rel="chapter" href="containers.html" title="Chapter 13: Containers">
<link rel="chapter" href="datastructures.html" title="Chapter 14: Data Structures">
<link rel="chapter" href="errorhandling.html" title="Chapter 15: Error Handling">
<link rel="chapter" href="castoperators.html" title="Chapter 16: Cast Operators">
<link rel="section" href="introduction.html#introduction_cpp_and_boost" title="1.1 C++ and Boost">
<link rel="section" href="introduction.html#introduction_development_process" title="1.2 Development Process">
<link rel="section" href="introduction.html#introduction_installation" title="1.3 Installation">
<link rel="section" href="introduction.html#introduction_overview" title="1.4 Overview">
<meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://www.highscore.de" r (nz 1 vz 1 lz 1 oz 1 cz 1) gen true for "http://highscore.de" r (nz 1 vz 1 lz 1 oz 1 cz 1))'>
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link href="http://www.highscore.de/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script><script type="text/javascript" src="js/jquery.event.drag-1.5.min.js"></script><script type="text/javascript" src="js/highscore.js"></script>
</head>
<body>
<div lang="en" class="docbook chapter" title="Chapter 1: Introduction">
<p class="title">The Boost C++ Libraries</p>
<script type="text/javascript">
          var titlepage = "Front page";
        
      var titles = new Array(titlepage,
      
        "Chapter 1: Introduction",
      
        "Chapter 2: Smart Pointers",
      
        "Chapter 3: Function Objects",
      
        "Chapter 4: Event Handling",
      
        "Chapter 5: String Handling",
      
        "Chapter 6: Multithreading",
      
        "Chapter 7: Asynchronous Input and Output",
      
        "Chapter 8: Interprocess Communication",
      
        "Chapter 9: Filesystem",
      
        "Chapter 10: Date and Time",
      
        "Chapter 11: Serialization",
      
        "Chapter 12: Parser",
      
        "Chapter 13: Containers",
      
        "Chapter 14: Data Structures",
      
        "Chapter 15: Error Handling",
      
        "Chapter 16: Cast Operators",
      
      "");

      
          var titlehtml = "frontpage.html";
        
      var filenames = new Array(titlehtml,
      
        "introduction.html",
      
        "smartpointers.html",
      
        "functionobjects.html",
      
        "eventhandling.html",
      
        "stringhandling.html",
      
        "multithreading.html",
      
        "asio.html",
      
        "interprocesscommunication.html",
      
        "filesystem.html",
      
        "datetime.html",
      
        "serialization.html",
      
        "parser.html",
      
        "containers.html",
      
        "datastructures.html",
      
        "errorhandling.html",
      
        "castoperators.html",
      
      "");

      
      document.open();
      document.write('<form action="" class="toc">');
      document.write('<select size="1" onchange="location.href=options[selectedIndex].value">');
      for (var i = 0; i < titles.length && i < filenames.length; ++i) {
        if (titles[i] != "" && filenames[i] != "") {
          document.write('<option');
          document.write(' value="' + filenames[i] + '"');
          var expr = new RegExp('[/\]' + filenames[i] + '$');
          if (expr.test(location.href)) {
            document.write(' selected="selected"');
          }
          document.write('>' + titles[i] + '<\/option>');
        }
      }
      document.write('<\/select>');
      document.write('<\/form>');
      document.close();
      
    </script><noscript><p class="toc"><a href="toc.html">Table of Contents</a></p></noscript>
<hr class="hrhead">
<h1 class="title">
<a name="introduction"></a><small>Chapter 1:</small> Introduction</h1>
<hr>
<div class="toc">
<h3>Table of Contents</h3>
<ul>
<li><span class="sect1"><a href="introduction.html#introduction_cpp_and_boost">1.1 C++ and Boost</a></span></li>
<li><span class="sect1"><a href="introduction.html#introduction_development_process">1.2 Development Process</a></span></li>
<li><span class="sect1"><a href="introduction.html#introduction_installation">1.3 Installation</a></span></li>
<li><span class="sect1"><a href="introduction.html#introduction_overview">1.4 Overview</a></span></li>
</ul>
</div>
<p class="license"><a href="http://creativecommons.org/licenses/by-nc-nd/3.0/" rel="license" target="_top"><img src="img/88x31_cc_logo.gif" alt="" width="88" height="31"></a> This book is licensed under a <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/" rel="license" target="_top">Creative Commons License</a>.</p>
<hr>
<h2 class="title">
<a name="introduction_cpp_and_boost"></a>1.1 C++ and Boost</h2>
<div class="sect1">
<p>The <a class="link" href="http://www.boost.org/doc/libs/">Boost C++ Libraries</a> are a collection of modern libraries based on the C++ standard. The source code is released under the <a class="link" href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a> allowing to use, modify and distribute the libraries for free. The libraries are platform independent and support most popular as well as many lesser known compilers.</p>
<p>The Boost community is responsible for developing and publishing the Boost C++ Libraries. It consists of a relatively large group of C++ developers from around the world coordinated through the web site <a class="link" href="http://www.boost.org/">www.boost.org</a> as well as several mailing lists. The mission statement of the community is to develop and collect libraries of high-quality that complement the C++ standard. Libraries that prove of value and become important for the development of C++ applications stand a good chance to get included in the C++ standard someday.</p>
<p>The Boost community emerged around 1998 when the first revision of the C++ standard was released. It has grown continuously since then and nowadays plays a big role in the standardization of C++. Even though there is no direct relation between the Boost community and the standardization committee, some of the developers are active in both groups. The next revision of the C++ standard, which is most likely approved in 2011, is going to be extended by a couple of libraries that have their roots in the Boost community.</p>
<p>Boost C++ Libraries are a good choice to increase the productivity of C++ projects after exhausting the C++ standard. Since C++ has evolved after the current revision of the C++ standard originated in 2003, Boost C++ Libraries offer many new features. Without waiting for the next revision of the C++ standard, progress made in the evolution of C++ can be utilized immediately thanks to the Boost C++ Libraries.</p>
<p>Due to the excellent reputation the Boost C++ Libraries have, being well grounded in using them certainly proves to be of value occupationally. It is not unusual to be asked about the Boost C++ Libraries during an interview since developers who know these libraries are usually also fond with the latest innovations of C++ and are able to write and understand modern C++ code.</p>
</div>
<hr>
<h2 class="title">
<a name="introduction_development_process"></a>1.2 Development Process</h2>
<div class="sect1">
<p>The development of the Boost C++ Libraries is only possible because individual developers or organizations support them with great engagement. Since Boost only accepts libraries that solve existing problems, exhibit a convincing design, are developed using modern C++ and are documented in an understandable way, each Boost C++ Library has a lot of work behind it.</p>
<p>C++ developers can engage themselves in the Boost community and propose new libraries. However, in order to convert an idea into a Boost C++ Library, a lot of time and effort needs to be invested. It is of vital importance to discuss the requirements and possible solutions with other developers and potential users in the Boost mailing lists. </p>
<p>Besides libraries that seem to appear from nowhere, it is also possible to nominate existing C++ libraries for the inclusion into Boost. However, since the requirements for these libraries are the same as for libraries developed for Boost in particular, there may be many changes required.</p>
<p>Whether or not a library gets accepted into Boost, depends on the outcome of the review process. Developers of libraries can apply for a review which usually takes places over the course of 10 days. During this time frame other developers are requested to rate the library. Based on the number of positive and negative reviews, the review manager decides whether or not the library is accepted into Boost. Since some developers are exposed to the library for the first time during the review, it is not uncommon that modifications to the library are requested during the time frame of the review.</p>
<p>If a library is rejected due to technical reasons, it is still possible to revise the library and request a new review for an updated version. However, if a library is rejected because it does not solve any practical problem or because it provides an unconvincing solution to an existing problem, there is a good chance that it will be again rejected during another review.</p>
<p>Because new libraries can be accepted at any time, a new version of the Boost C++ Libraries is released every three months. This book covers libraries found in version 1.42.0 which was released in February 2010.</p>
<p>Please note that there exists additional libraries that have been already accepted but are not part of the official release of the Boost C++ Libraries yet. They have to be manually installed until they get included.</p>
</div>
<hr>
<h2 class="title">
<a name="introduction_installation"></a>1.3 Installation</h2>
<div class="sect1">
<p>The Boost C++ Libraries come as source code. While most of the libraries consist solely of header files that can be directly used, some of the libraries requires compilation. In order to make the installation process as easy as possible, an automated installation process using <span class="application">Boost Jam</span> is available. Instead of validating and compiling individual libraries separately, <span class="application">Boost Jam</span> installs the complete set automatically. It supports many operating systems and compilers and knows how to compile each individual library based on appropriate configuration files.</p>
<p>To automatically install the Boost C++ Libraries with the aid of <span class="application">Boost Jam</span>, an application named <span class="command"><strong>bjam</strong></span> is utilized which is also available as source code. For some operating systems, including Windows and Linux, precompiled binaries of <span class="command"><strong>bjam</strong></span> are available as well.</p>
<p>In order to compile <span class="command"><strong>bjam</strong></span> itself, a simple script named <span class="command"><strong>build</strong></span> is executed which is available with the source code and is provided for different operating systems as well. For Windows, it is implemented as the batch file <code class="filename">build.bat</code>. For Linux, the file is called <code class="filename">build.sh</code>.</p>
<p>If <span class="command"><strong>build</strong></span> is called without any command line option, the script tries to find a suitable compiler to generate <span class="command"><strong>bjam</strong></span>. Using a command line switch, denoted as toolset, a particular compiler can be selected though. For Windows, <span class="command"><strong>build</strong></span> supports the toolsets <code class="literal">vc7</code>, <code class="literal">vc8</code> and <code class="literal">vc9</code> to select different versions of the Microsoft C++ compiler. To compile <span class="command"><strong>bjam</strong></span> with the C++ compiler from Visual Studio 2008, the command <span class="command"><strong>build vc9</strong></span> needs to be issued. For Linux, the toolsets <code class="literal">gcc</code> and <code class="literal">intel-linux</code> are supported, amongst others, to select the C++ compiler of GCC and Intel, respectively.</p>
<p>The application <span class="command"><strong>bjam</strong></span> must be copied to the local Boost directory - disregarding whether it was compiled or downloaded as a precompiled binary. <span class="command"><strong>bjam</strong></span> can then be started without any command line option to compile and install the Boost C++ Libraries. Since the default options - used in this case - are not always the best choice, the most important options are listed below:</p>
<div class="itemizedlist"><ul class="itemizedlist">
<li class="listitem"><p>The declaration of <code class="literal">stage</code> or <code class="literal">install</code> specifies whether the Boost C++ Libraries are installed in a subdirectory named <code class="filename">stage</code> or system-wide. The meaning of system-wide depends on the operating system. In Windows, the target directory is <code class="filename">C:\Boost</code>; in Linux it is <code class="filename">/usr/local</code>. The target directory can also be explicitly specified using the <code class="option">--prefix</code> option.</p></li>
<li class="listitem"><p>If <span class="command"><strong>bjam</strong></span> is called without any command line options, it will search for a suitable C++ compiler itself. A specific compiler can be selected using the <code class="option">--toolset</code> option. To specify the Microsoft C++ compiler from Visual Studio 2008 in Windows, <span class="command"><strong>bjam</strong></span> needs to be called with the <code class="option">--toolset=msvc-9.0</code> option. To specify the GCC compiler in Linux, the option <code class="option">--toolset=gcc</code> must be selected.</p></li>
<li class="listitem"><p>The command line option <code class="option">--build-type</code> determines which builds of the libraries are created. By default, this option is set to <code class="literal">minimal</code>, meaning that only release builds are created. This may become an issue for developers who want to create debug builds of their projects with Visual Studio or GCC. Since these compilers automatically try to link against the debug builds of the Boost C++ Libraries, an error message is displayed accordingly. In this case the option <code class="option">--build-type</code> should be set to <code class="literal">complete</code> to generate both debug and release builds of the Boost C++ Libraries which, however, will take much longer.</p></li>
</ul></div>
<p>To create both debug and release builds of the Boost C++ Libraries using the C++ compiler from Visual Studio 2008 and install them in the directory <code class="filename">D:\Boost</code>, the command executed is <span class="command"><strong>bjam --toolset=msvc-9.0 --build-type=complete --prefix=D:\Boost install</strong></span>. To create them in Linux using the default directory, the command executed is <span class="command"><strong>bjam --toolset=gcc --build-type=complete install</strong></span>.</p>
<p>There exist many other command line options which can be used to specify in detail how to compile the Boost C++ Libraries. I typically use the following command in Windows: <span class="command"><strong>bjam --toolset=msvc-9.0 debug release link=static runtime-link=shared install</strong></span>. <code class="literal">debug</code> and <code class="literal">release</code> cause both debug and release builds to be generated. <code class="literal">link=static</code> only creates static libraries. <code class="literal">runtime-link=shared</code> specifies that the C++ runtime library is dynamically linked which is the default setting for C++ projects in Visual Studio 2008.</p>
</div>
<hr>
<h2 class="title">
<a name="introduction_overview"></a>1.4 Overview</h2>
<div class="sect1">
<p>Version 1.42.0 of the Boost C++ Libraries contains more than 90 libraries out of which this book discusses the following libraries in more detail:</p>
<table border="0" cellspacing="0" cellpadding="0" id="id400448">
<caption>Table 1.1. Covered Libraries</caption>
<tr>
        <th>Boost C++ Library</th>
        <th>C++ Standard</th>
        <th>Short Description</th>
      </tr>
<tr>
        <td><a class="link" href="datastructures.html#datastructures_any" title="14.3 Boost.Any">Boost.Any</a></td>
        <td></td>
        <td>Boost.Any provides a data type named <code class="classname">boost::any</code> that allows to store arbitrary types. For example, a variable of type <code class="classname">boost::any</code> can first store a value of type <code class="type">int</code> before replacing it with a string of type <code class="type">std::string</code>.</td>
      </tr>
<tr>
        <td><a class="link" href="containers.html#containers_array" title="13.2 Boost.Array">Boost.Array</a></td>
        <td>TR1</td>
        <td>Boost.Array allows treating C++ arrays just like containers from the C++ standard.</td>
      </tr>
<tr>
        <td><a class="link" href="asio.html" title="Chapter 7: Asynchronous Input and Output">Boost.Asio</a></td>
        <td>TR2</td>
        <td>Boost.Asio allows to develop applications that process data asynchronously such as network applications.</td>
      </tr>
<tr>
        <td><a class="link" href="containers.html#containers_bimap" title="13.5 Boost.Bimap">Boost.Bimap</a></td>
        <td></td>
        <td>Boost.Bimap provides a class named <code class="classname">boost::bimap</code> which is similar to <code class="classname">std::map</code>. The crucial difference is that <code class="classname">boost::bimap</code> allows to search for both key and value.</td>
      </tr>
<tr>
        <td><a class="link" href="functionobjects.html#functionobjects_bind" title="3.2 Boost.Bind">Boost.Bind</a></td>
        <td>TR1</td>
        <td>Boost.Bind is kind of an adapter allowing to pass functions as template parameters even if the function signature is incompatible with the template parameter.</td>
      </tr>
<tr>
        <td><a class="link" href="castoperators.html#castoperators_conversion" title="16.2 Boost.Conversion">Boost.Conversion</a></td>
        <td></td>
        <td>Boost.Conversion provides three casting operators to perform downcasts, cross casts and to convert between values of different numeric types.</td>
      </tr>
<tr>
        <td><a class="link" href="datetime.html" title="Chapter 10: Date and Time">Boost.DateTime</a></td>
        <td></td>
        <td>Boost.DateTime can be used to process, read and write date and time values with a flexible formatting.</td>
      </tr>
<tr>
        <td><a class="link" href="errorhandling.html#errorhandling_exception" title="15.3 Boost.Exception">Boost.Exception</a></td>
        <td></td>
        <td>Boost.Exception allows adding additional data to thrown exceptions in order to provide more information in the <code class="code">catch</code> handler. This helps easing the debugging process and allows better responding to exceptional cases.</td>
      </tr>
<tr>
        <td><a class="link" href="filesystem.html" title="Chapter 9: Filesystem">Boost.Filesystem</a></td>
        <td>TR2</td>
        <td>Boost.Filesystem offers a class for processing of path information and also contains several functions to access files and directories.</td>
      </tr>
<tr>
        <td><a class="link" href="stringhandling.html#stringhandling_format" title="5.6 Boost.Format">Boost.Format</a></td>
        <td></td>
        <td>Boost.Format replaces the <code class="function">std::printf()</code> function with a type-safe and extendable <code class="classname">boost::format</code> class.</td>
      </tr>
<tr>
        <td><a class="link" href="functionobjects.html#functionobjects_function" title="3.4 Boost.Function">Boost.Function</a></td>
        <td>TR1</td>
        <td>Boost.Function simplifies the definition of function pointers.</td>
      </tr>
<tr>
        <td><a class="link" href="interprocesscommunication.html" title="Chapter 8: Interprocess Communication">Boost.Interprocess</a></td>
        <td></td>
        <td>Boost.Interprocess allows applications to communicate via shared memory in a fast and efficient manner.</td>
      </tr>
<tr>
        <td><a class="link" href="functionobjects.html#functionobjects_lambda" title="3.5 Boost.Lambda">Boost.Lambda</a></td>
        <td></td>
        <td>Boost.Lambda allows the definition of anonymous functions. Code is declared and executed inline to avoid separate function calls.</td>
      </tr>
<tr>
        <td><a class="link" href="containers.html#containers_multiindex" title="13.4 Boost.MultiIndex">Boost.Multiindex</a></td>
        <td></td>
        <td>Boost.Multiindex allows defining new containers that can support multiple interfaces such as the ones from <code class="classname">std::vector</code> and <code class="classname">std::map</code>.</td>
      </tr>
<tr>
        <td><a class="link" href="castoperators.html#castoperators_numeric_conversion" title="16.3 Boost.NumericConversion">Boost.NumericConversion</a></td>
        <td></td>
        <td>Boost.NumericConversion provides a cast operator to safely convert between values of different numeric types without generating an overflow or underflow condition.</td>
      </tr>
<tr>
        <td><a class="link" href="smartpointers.html#smartpointers_pointer_container" title="2.9 Pointer Container">Boost.PointerContainer</a></td>
        <td></td>
        <td>Boost.PointerContainer provides containers optimized for the management of dynamically allocated objects.</td>
      </tr>
<tr>
        <td><a class="link" href="functionobjects.html#functionobjects_ref" title="3.3 Boost.Ref">Boost.Ref</a></td>
        <td>TR1</td>
        <td>The adapters of Boost.Ref allow passing references to uncopyable objects to functions that expect copies.</td>
      </tr>
<tr>
        <td><a class="link" href="stringhandling.html#stringhandling_regex" title="5.4 Boost.Regex">Boost.Regex</a></td>
        <td>TR1</td>
        <td>Boost.Regex offers functions to search text via regular expressions.</td>
      </tr>
<tr>
        <td><a class="link" href="serialization.html" title="Chapter 11: Serialization">Boost.Serialization</a></td>
        <td></td>
        <td>Via Boost.Serialization, objects can be serialized and e.g. stored in files that can be loaded later on.</td>
      </tr>
<tr>
        <td><a class="link" href="eventhandling.html" title="Chapter 4: Event Handling">Boost.Signals</a></td>
        <td></td>
        <td>Boost.Signal is a framework for event handling and is based on the so-called signal/slot concept: Functions are associated with signals and automatically called, when the signal is triggered.</td>
      </tr>
<tr>
        <td><a class="link" href="smartpointers.html" title="Chapter 2: Smart Pointers">Boost.SmartPoiners</a></td>
        <td>TR1</td>
        <td>Boost.SmartPoiners offers many smart pointers simplifying the management of dynamically allocated objects.</td>
      </tr>
<tr>
        <td><a class="link" href="parser.html" title="Chapter 12: Parser">Boost.Spirit</a></td>
        <td></td>
        <td>Boost.Spirit allows generating parsers using a syntax similar to EBNF (Extended Backus Naur Form).</td>
      </tr>
<tr>
        <td><a class="link" href="stringhandling.html#stringhandling_stringalgorithms" title="5.3 Boost.StringAlgorithms">Boost.StringAlgorithms</a></td>
        <td></td>
        <td>Boost.StringAlgorithms provides many stand-alone functions to facilitate string handling.</td>
      </tr>
<tr>
        <td><a class="link" href="errorhandling.html#errorhandling_system" title="15.2 Boost.System">Boost.System</a></td>
        <td>TR2</td>
        <td>Boost.System offers a framework to process system- and application-specific error codes.</td>
      </tr>
<tr>
        <td><a class="link" href="multithreading.html" title="Chapter 6: Multithreading">Boost.Thread</a></td>
        <td>C++0x</td>
        <td>Boost.Thread allows developing multithreaded applications.</td>
      </tr>
<tr>
        <td><a class="link" href="stringhandling.html#stringhandling_tokenizer" title="5.5 Boost.Tokenizer">Boost.Tokenizer</a></td>
        <td></td>
        <td>Boost.Tokenizer allows iterating over the individual components of a string.</td>
      </tr>
<tr>
        <td><a class="link" href="datastructures.html#datastructures_tuple" title="14.2 Boost.Tuple">Boost.Tuple</a></td>
        <td>TR1</td>
        <td>Boost.Tuple offers a generalized version of <code class="classname">std::pair</code> that allows grouping of any number of data.</td>
      </tr>
<tr>
        <td><a class="link" href="containers.html#containers_unordered" title="13.3 Boost.Unordered">Boost.Unordered</a></td>
        <td>TR1</td>
        <td>Boost.Unordered enlarges the containers of the C++ standard by adding <code class="classname">boost::unordered_set</code> and <code class="classname">boost::unordered_map</code>.</td>
      </tr>
<tr>
        <td><a class="link" href="datastructures.html#datastructures_variant" title="14.4 Boost.Variant">Boost.Variant</a></td>
        <td></td>
        <td>Boost.Variant permits the definition of data types that, similar to <code class="code">union</code>, group multiple data types. The advantage of Boost.Variant  over <code class="code">union</code> is the possibility to use classes as well.</td>
      </tr>
</table>
<p>While the Technical Report 1 was published in 2003, details about the standardization in regards to C++0x and the Technical Report 2 illustrate the current status quo. Since neither the next revision of the C++ standard nor the Technical Report 2 has been approved yet, they may still change in the future.</p>
</div>
</div>
<hr class="hrfoot">
<p class="copyright">Copyright © 2008-2010 
        <a class="link" href="mailto:boris@highscore.de">Boris Schäling</a>
      </p>
</body>
</html>
